package com.raulraja.view.demo;

import com.raulraja.view.manager.PersonViewManager;
import com.raulraja.dto.PersonDTO;
import org.springframework.web.HttpRequestHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Demo handler to demonstrate layers call stack
 */
public class LayerDemoHandlerImpl implements HttpRequestHandler {

	private PersonViewManager personViewManager;

	public void setPersonViewManager(PersonViewManager personViewManager) {
		this.personViewManager = personViewManager;
	}

	/**
	 * Process the given request, generating a response.
	 *
	 * @param request  current HTTP request
	 * @param response current HTTP response
	 * @throws javax.servlet.ServletException in case of general errors
	 * @throws java.io.IOException			in case of I/O errors
	 */
	public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PersonDTO personDTO = new PersonDTO();
		personDTO.setId(1L);
		personViewManager.getPerson(personDTO);
	}
}
